// PersisterFacadeImp.h: interface for the PersisterFacadeImp class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PERSISTERFACADEIMP_H__3ED9DD64_9F8C_47EC_B251_326B662C66BB__INCLUDED_)
#define AFX_PERSISTERFACADEIMP_H__3ED9DD64_9F8C_47EC_B251_326B662C66BB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "PersisterFacade.h"
#include "DatabaseBase.h"
#include "ManagerTemplate.h"

namespace PDMS
{
	namespace PDMSDBIF
	{
		class PersisterFacadeImp : public PDMSFrame::PersisterFacade  
		{
			struct ClassInfo : public SmallObject
			{
				UeObjectId id;
				StdString m_strClassName;
				StdString m_strObjectName;
			};

			typedef ManagerTemplate< UeObjectId, ClassInfo > ClassInfoMap;

			DECLARE_DYNAMIC_CREATE( PersisterFacadeImp );
		public:
			PersisterFacadeImp();
			virtual ~PersisterFacadeImp();
			
		protected:
			UESoft::ErrorStatus SaveClassInfo( Persistable* pObj );

		public:
			virtual UESoft::ErrorStatus Save( Persistable* pObj );
			virtual UESoft::ErrorStatus SaveDBInfo( PDMSPerObjManager* pManager );
			virtual UESoft::ErrorStatus ReadDBInfo( PDMSPerObjManager* pManager );
			virtual UESoft::ErrorStatus Read( const UeObjectId& id, Persistable*& pObj );
			virtual UESoft::ErrorStatus Open();
			virtual UESoft::ErrorStatus Close();

		private:
			BOOL m_bIsOpen;
			BOOL m_bHasRunSave;
			DatabaseBase m_DesignDB;
			ClassInfoMap m_ClassInfoMap;
		};
	}
}

#endif // !defined(AFX_PERSISTERFACADEIMP_H__3ED9DD64_9F8C_47EC_B251_326B662C66BB__INCLUDED_)
